<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type='text/javascript' src='../js/vue.js'></script>
    <script type='text/javascript' src=''></script>

</head>

<body>
    <!-- 
        VueComponent.prototype.__proto__ ==Vue.prototype
        让组件实例对象（vc）可以访问到Vue原型上的属性、方法

 -->
    <div id="root">
        <school></school>
    </div>
    <script>
        Vue.config.productionTip = false;
        Vue.prototype.x = 1;


        const school = Vue.extend({
            template: `
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <button @click='showName'>点我提示学校名</button>
                </div>
            `,
            data() {
                return {
                    schoolName: 'CQBZ',
                    address: 'CQ',
                }
            },
            methods: {
                showName() {
                    console.log('showName', this)
                    alert(this.schoolName)
                    console.log(this.x)//从原型获得
                }
            }
        })
        const vm = new Vue({
            el: '#root',
            components: {
                school
            }
        })

        console.log(school.prototype.__proto__ ==Vue.prototype)

        /*
        //定义一个构造函数
        function Demo() {
            this.a = 1
            this.b = 2
        }
        const d = new Demo()

        // console.log(Demo.prototype)//显示原型属性
        // console.log(d.__proto__)//隐式原型属性

        Demo.prototype.x = 99;

        // console.log('@', d)
        */

    </script>
</body>

</html>